package besta.moon.sql.expression.function.string;

import besta.moon.sql.expression.function.FunctionReturnString;
import besta.moon.sql.parser.SQLTokenizer;

public class FunctionChar extends FunctionReturnString {

    @Override
    public final int getFunction() {
        return SQLTokenizer.CHAR;
    }

    @Override
    public final String getString() throws Exception {
        if (isNull()) {
            return null;
        }
        char chr = (char) param1.getInt();
        return String.valueOf(chr);
    }

    @Override
    public final int getDataType() {
        return SQLTokenizer.CHAR;
    }

    @Override
    public final int getPrecision() {
        return 1;
    }
}
